package com.excilys.converter;

import org.springframework.stereotype.Component;

import com.excilys.dto.UserDTO;
import com.excilys.model.User;

/**
 * Converter that allows to switch from the DTO User model to the original User
 * model
 * 
 * @author excilys dev: GF
 * 
 */
@Component
public class UserDTOToUserConverter {

	public User convert(UserDTO userDTO) {

		User user = new User();

		user.setUserLogin(userDTO.getUserDTOLogin());
		user.setUserFirstName(userDTO.getUserDTOFirstName());
		user.setUserLastName(userDTO.getUserDTOLastName());
		user.setUserListAccounts(null);
		user.setUserPassword("37a8eec1ce19687d132fe29051dca629d164e2c4958ba141d5f4133a33f0688f");
		user.setUserRole("ROLE_DEFAULT");
		user.setEnabled(true);
		user.setUserTargetAccounts(null);

		return user;
	}

}